package controllers

import (
	"gdshop-back-end-go/client-api/app/request/FenxiaoReq"
	"gdshop-back-end-go/client-api/app/service/FenxiaoService"
	"gdshop-back-end-go/common/libs/token"
	"gdshop-back-end-go/common/response"
	"github.com/gogf/gf/net/ghttp"
)

type FenxiaoController struct {
	*BaseController
}

func (c *FenxiaoController) Init(r *ghttp.Request) *response.JsonResponse {
	memberId = token.GetLoginMemberId(r)
	if memberId < 1 {
		return response.FailByRequestMessage(r, "获取会员ID失败")
	}
	return response.SuccessByRequest(r)
}

func (c *FenxiaoController) Index(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.Index
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.Index(r.GetCtx(), parames)
}

func (c *FenxiaoController) GetMemberWithdraw(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.GetMemberWithdraw
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.GetMemberWithdraw(r.GetCtx(), parames)
}

func (c *FenxiaoController) SubmitWithdrawApply(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.SubmitWithdrawApply
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.SubmitWithdrawApply(r.GetCtx(), parames)
}

func (c *FenxiaoController) BillList(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.BillList
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.BillList(r.GetCtx(), parames)
}

func (c *FenxiaoController) WithdrawList(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.WithdrawList
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.WithdrawList(r.GetCtx(), parames)
}

func (c *FenxiaoController) GoodsList(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.GoodsList
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.GoodsList(r.GetCtx(), parames)
}

func (c *FenxiaoController) GoodsFollowChange(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.GoodsFollowChange
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.GoodsFollowChange(r.GetCtx(), parames)
}

func (c *FenxiaoController) GoodsFollowList(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.GoodsFollowList
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.GoodsFollowList(r.GetCtx(), parames)
}

func (c *FenxiaoController) GoodsFollowDel(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.GoodsFollowDel
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.GoodsFollowDel(r.GetCtx(), parames)
}

func (c *FenxiaoController) TeamList(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.TeamList
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.TeamList(r.GetCtx(), parames)
}

func (c *FenxiaoController) OrderList(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.OrderList
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.OrderList2(r.GetCtx(), parames)
}

func (c *FenxiaoController) MyPromoteCodeImg(r *ghttp.Request) *response.JsonResponse {
	var parames *FenxiaoReq.MyPromoteCodeImg
	if err := r.Parse(&parames); err != nil {
		return response.FailByRequestMessage(r, err.Error())
	}
	parames.MemberId = memberId
	return FenxiaoService.MyPromoteCodeImg(r.GetCtx(), parames)
}
